home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / perlmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-29  |  2.9 KB  |  138 lines  |  [TEXT/MPS ]

  1. /*
  2.  * "The Road goes ever on and on, down from the door where it began."
  3.  */
  4.  
  5. #ifdef macintosh
  6. #include <Types.h>
  7. #if __profile__
  8. #include <profiler.h>
  9. #endif
  10. #include "EXTERN.h"
  11. #include "icemalloc.h"
  12. #else
  13. #include "INTERN.h"
  14. #endif
  15. #include "perl.h"
  16.  
  17. static void xs_init _((void));
  18. static PerlInterpreter *my_perl;
  19.  
  20. /* This value may be raised by extensions for testing purposes */
  21. int perl_destruct_level = 0; /* 0=none, 1=full, 2=full with checks */
  22.  
  23. int
  24. main(argc, argv, env)
  25. int argc;
  26. char **argv;
  27. char **env;
  28. {
  29.     int exitstatus;
  30.  
  31. #ifdef VMS
  32.     getredirection(&argc,&argv);
  33. #endif
  34.  
  35. #ifdef macintosh
  36. #if __profile__
  37.    ProfilerInit(collectDetailed, bestTimeBase, 1000, 30);
  38. #endif
  39.    mac_initminiperl();
  40.    init_env(env);
  41. #endif
  42.  
  43. #ifdef macintosh
  44.     {
  45. #else
  46.     if (!do_undump) {
  47. #endif
  48. #ifdef MALLOC_LOG
  49.     MallocLog("Allocating...\n");
  50. #endif
  51.     my_perl = perl_alloc();
  52.     if (!my_perl)
  53.         exit(1);
  54. #ifdef macintosh
  55.        curinterp = my_perl;
  56. #endif
  57. #ifdef MALLOC_LOG
  58.     MallocLog("Constructing...\n");
  59. #endif
  60.     perl_construct( my_perl );
  61.     }
  62.     
  63. #ifdef MALLOC_LOG
  64.     MallocLog("Parsing...\n");
  65. #endif
  66.     exitstatus = perl_parse( my_perl, xs_init, argc, argv, env );
  67.     if (!exitstatus) {
  68. #ifdef MALLOC_LOG
  69.     MallocLog("Running...\n");
  70. #endif
  71.         exitstatus = perl_run( my_perl );
  72.     } else if (perl_destruct_level) {
  73.         /* Shut up checks */
  74.         perl_destruct_level = 1;
  75.     }
  76.     
  77. #ifdef MALLOC_LOG
  78.     MallocLog("Destructing...\n");
  79. #endif
  80.     perl_destruct( my_perl, perl_destruct_level );
  81. #ifdef MALLOC_LOG
  82.     MallocLog("Freeing...\n");
  83. #endif
  84.     perl_free( my_perl );
  85. #ifdef MALLOC_LOG
  86.     MallocLog("That's all, folks...\n");
  87. #endif
  88.  
  89. #ifdef macintosh
  90. #if __profile__
  91.     ProfilerDump("\pMiniperl.Prof");
  92.     ProfilerTerm();
  93. #endif
  94. #endif
  95.  
  96.     exit( exitstatus );
  97.  
  98. #ifdef macintosh    
  99.     return 0;
  100. #endif
  101. }
  102.  
  103. /* Register any extra external extensions */
  104.  
  105. static void
  106. xs_init()
  107. {
  108.     char *file = __FILE__;
  109.     {   extern void boot_MacPerl _((CV* cv));
  110.         newXS("MacPerl::bootstrap", boot_MacPerl, file);
  111.     }
  112.     {   extern void boot_DynaLoader _((CV* cv));
  113.         newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
  114.     }
  115.     {   extern void boot_NDBM_File _((CV* cv));
  116.         newXS("NDBM_File::bootstrap", boot_NDBM_File, file);
  117.     }
  118.     {   extern void boot_DB_File _((CV* cv));
  119.         newXS("DB_File::bootstrap", boot_DB_File, file);
  120.     }
  121.     {   extern void boot_Socket _((CV* cv));
  122.         newXS("Socket::bootstrap", boot_Socket, file);
  123.     }
  124.     {   extern void boot_Fcntl _((CV* cv));
  125.         newXS("Fcntl::bootstrap", boot_Fcntl, file);
  126.     }
  127.     {   extern void boot_POSIX _((CV* cv));
  128.         newXS("POSIX::bootstrap", boot_POSIX, file);
  129.     }
  130.     {   extern void boot_OSA _((CV* cv));
  131.         newXS("OSA::bootstrap", boot_OSA, file);
  132.     }
  133.     {   extern void boot_XL _((CV* cv));
  134.         newXS("XL::bootstrap", boot_XL, file);
  135.     }
  136.     autoboot_preamble = "BEGIN { bootstrap MacPerl; bootstrap OSA; bootstrap XL;  }";
  137. }
  138.